

public class BinaryTree {
    public static class Node {
        public int value;
        public Node left;
        public Node right;

        public Node(int value) {
            this.value = value;
        }
    }

    //    前序遍历
    public static void prePrint(Node head) {
        if (head == null) {
            return;
        }
        System.out.println(head.value + "");
        prePrint(head.left);
        prePrint(head.right);
    }

    //  中序遍历
    public static void midPrint(Node head) {
        if (head == null) {
            return;
        }
        midPrint(head.left);
        System.out.println(head.value + ",");
        midPrint(head.right);
    }

    //后续遍历
    public static void lastPrint(Node head) {
        if (head == null) {
            return;
        }
        lastPrint(head.left);
        lastPrint(head.right);
        System.out.println(head.value + ",");
    }
}
